lockKey=""; $usr = new user(); $data = $usr->_getUserContext(); $idPre.=$data->id.'-'; parent::__construct($id,$cBy,$uBy,$idPre,$cType,$classN,$flowName); //$this->className = get_class();// Set current class $this->flowCurrStep = "START"; $this->zBrowseList = array("workId", "createDate","updateDate","userType","currentStatus");//zBlob should not be here $this->zColumnList = array("workId", "createDate","updateDate","userType","currentStatus","zBlob"); $this->zColumnType = array("VARCHAR(32)", "VARCHAR(32)","VARCHAR(32)","VARCHAR(32)","VARCHAR(64)","LONGTEXT"); } public function _update($id="",$TeamID="",$ItemID="",$RelatedUser="",$AmountIn=0,$AmountOut=0,$Comments=""){ if($id!="" && ($AmountIn>0 || $AmountOut>0)){ $this->_openById($id); if($TeamID!="") $this->TeamID=$TeamID; if($ItemID!="" ) $this->ItemID=$ItemID; if($RelatedUser!="") $this->RelatedUser=$RelatedUser; if($AmountIn>0) $this->AmountIn=$AmountIn; if($AmountOut>0) $this->AmountOut=$AmountOut; if($Comments!="") $this->Comments=$Comments; $this->_save(); } } public function resetParam($id=""){ if($id==""){ $f = new flow($this->flowName); $obj = $f->_getStepDetails($this->flowCurrStep); $params = new stdClass; $params->display = $obj->display; $params->stageId = $obj->id; $params->screen = $obj->screen; $params->caseID = $this->workId; $usr = new user; $data = $usr->_getUserContext(); $params->userID = $data->workId; $params->userGroup = $data->userGroup; return _encodeUrl($params); }else{ $lr = new leaveReq(); $lr->_openById($id); $f = new flow($lr->flowName); $obj = $f->_getStepDetails($lr->flowCurrStep); $params = new stdClass; $params->display = $obj->display; $params->stageId = $obj->id; $params->screen = $obj->screen; $params->caseID = $lr->workId; $usr = new user; $data = $usr->_getUserContext(); $params->userID = $data->workId; $params->userGroup = $data->userGroup; return _encodeUrl($params); } } public function callWhen($wName){// calls user defined functions manually _log("Method > callWhen() > When $wName not defined by user!","abc"); if (function_exists($wName)) { $usr = new user(); $data = $usr->_getUserContext(); if(call_user_func($wName, $this,$data)==true){ //echo "xx";exit; return true; } } return false; } public function isManager(){ return true; } public function hasAccess(){ return true; } public function ifGtr10Days(){ if($this->dayDiff>=10) return true; else return false; } public function ifLtr10Days(){ if($this->dayDiff<10) return true; else return false; } public function isApproved(){ if($this->managerAction=="approve") return true; else return false; } public function isRejected(){ if($this->managerAction=="reject") return true; else return false; } public function isMoreInforReq(){ if($this->managerAction=="moreInfo") return true; else return false; } public function IfNotRequired(){ if($this->ifNotRequired==true || $this->ifNotRequired==1) return true; else return false; } public function addHistory(){ $f = new flow($this->flowName); $obj = $f->_getStepDetails($this->flowCurrStep); addHistory(caseID:$this->workId,note:$this->stepName.' completed, '.$obj->description); } } function addHistory($caseID,$note){ $usr = new user(); $data = $usr->_getUserContext(); $fh = new history(cBy:$data->workId,objectID:$caseID,actionPerformed:$note); } function hasRole($userID="",$requiredRole="USR") { $usr = new user(); $data = $usr->_getUserContext(); if($userID=="" || $data->workId==$userID){ return $data->role===$requiredRole; }else{ $tmpObj = $usr->_browse(select:"role",where:"workId='$userID'",isExecute:true); if($tmpObj->status==true){ return $tmpObj->results[0]->role===$requiredRole; } return false; } return false; } function isAdmin($userID=""){ return hasRole($userID,"ADM"); } function isUser($userID=""){ return hasRole($userID,"USR"); } function isManager($userID=""){ return hasRole($userID,"MGR"); } function addTransactionFromAPI($contact="",$item="I-8",$type="owner",$amount=0,$comments=""){ $usr = new user(); $uList = $usr->_list(select:"workId,orgID,userGroup",where:"contact='$contact'"); if($uList->resultsCount==1){ if($type=="O"){ $t = new transaction(OrgID:$uList->results[0]->orgID,cBy:$uList->results[0]->workId,TeamID:$uList->results[0]->userGroup,ItemID:$item,AmountIn:$amount,Comments:$comments,RelatedUser:$uList->results[0]->userName); }elseif($type=="T"){ $t = new transaction(OrgID:$uList->results[0]->orgID,cBy:$uList->results[0]->workId,TeamID:$uList->results[0]->userGroup,ItemID:$item,AmountOut:$amount,Comments:$comments,RelatedUser:$uList->results[0]->userName); }else{} } } /* $a = new history(); $lst = $a->_list(where:1); echo json_encode($lst); */ //Run first tiome to generate tables /* $o = new organization(); $o->_createTable(true); $org = new organization(oNam:"LeaveMgmt"); $orgId = $org->dataId; echo "Organization Created ID#$orgId
"; $t = new team(); $t->_createTable(true); $tm = new team(tNam:"Default",oId:$orgId); $tmId= $tm->dataId; echo "Team Created ID#$tmId
"; $ad = new address(); $ad->_createTable(true); $tr = new leaveReq(); $tr->_createTable(true); echo "Table Created for Address & Transactions
"; $u = new user(); $u->_createTable(true); $flg= $u->_addNewUser(name:"Rajat",email:"rajat70@gmail.com",contact:"9748448117",teamId:$tmId,orgID:$orgId); echo "User #$u->workId created
"; $u = new history(); $u->_createTable(true); $u = new lock(); $u->_createTable(true); $u = new assign(); $u->_createTable(true); $u = new sla(); $u->_createTable(true); */ // $r = new product(orgId:"ORG-5",name:"Maggie",desc:"2 min Magie",category_id:"C-1",unit_price:12.0,uom:"packs",cBy:"Rajat",uBy:"Rajat"); //$r = new product(); //echo json_encode($r); // $r->_createTable(true); // echo json_encode($r->FlowData); // $c = new company(name:"abc",desc:"new createion"); // $c->_createTable(true); $s = new stock(); $s->_updateStock(product_id:"P-5",count:10,flag:""); // $s->_createTable(true); ?>